package com.bjx.flow.mmx.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjx.flow.mmx.domain.entity.MmxFlowBranchEntity;
import com.bjx.flow.mmx.mapper.MmxFlowBranchMapper;
import com.bjx.flow.mmx.service.MmxFlowBranchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @desc: 流程分支服务实现
 * @author: liushuai
 * @date: 2023/05/26
 */
@Service
public class MmxFlowBranchServiceImpl extends ServiceImpl<MmxFlowBranchMapper, MmxFlowBranchEntity> implements MmxFlowBranchService {
    @Autowired
    private MmxFlowBranchMapper flowBranchMapper;


    @Override
    public void updateNodeIdByBranchId(String id, Long branchId) {
        //根据分支id修改节点id
        LambdaUpdateWrapper<MmxFlowBranchEntity> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(MmxFlowBranchEntity::getBranchId, branchId);
        updateWrapper.set(MmxFlowBranchEntity::getNodeId, id);
        flowBranchMapper.update(null, updateWrapper);
    }

    @Override
    public void insertBranch(MmxFlowBranchEntity branch) {
        //插入分支后，替换节点id
        flowBranchMapper.insert(branch);
    }
}
